#include <iostream>
#include "vectorfunctions.h"

int sum_by_k(int x[], int l, int s[], int k)
{
	int i, j, a, ls=0;
		for (i=0;i<l-k+1;i++){
			a=i;
			s[ls]=0;
			for (j=0;j<k;j++){				
				s[ls] += x[a];
				++a;
			}
			++ls;
		}
return ls;
}

int main()
{
	int l, max, k, length_s;
	int x[100], sums[100];
	cout<<"Length of array : ";
	cin>>l;
	readVector(x, l);
	cout<<"Elements : ";
	cin>>k;
	length_s = sum_by_k(x, l, sums, k);
	printVector(sums, length_s);
	max=maxofVector(sums, length_s);
	cout<<"Maximum sum is : "<<max<<"\n";
return 0;
}
